package com.example.votesystem.service;

import com.example.votesystem.dao.TGroupMapper;
import com.example.votesystem.pojo.TGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CheckGroupService {
    @Autowired
    private TGroupMapper tGroupMapper;
    /**
     * 新增
     * @param group
     */
    public void add(String group) {
        TGroup tGroup = new TGroup();
        tGroup.setName(group);
        tGroupMapper.insert(tGroup);
    }

    /**
     * 修改
     * @param id
     * @param group
     */
    public void update(Integer id, String group) {
        TGroup tGroup = new TGroup();
        tGroup.setId(id);
        tGroup.setName(group);
        tGroupMapper.updateById(tGroup);
    }

    /**
     *查询
     * @return
     */
    public List<TGroup> findAll() {
        return tGroupMapper.findAll();
    }

    public void delete(Integer id) {
        tGroupMapper.deleteById(id);
    }
}
